package org.zxt.web.context;

import org.zxt.web.context.handler.RequestMapperHandler;
import org.zxt.web.nio.IHTTPSession;
import org.zxt.web.nio.Response;
import org.zxt.web.nio.Status;

import java.lang.reflect.Method;

import static org.zxt.web.nio.NioHTTPD.MIME_HTML;

public class HealthRequestMapperHandler implements RequestMapperHandler {
    @Override
    public Object[] parseArguments(WebContext webContext, IHTTPSession session) {
        return new Object[]{
                webContext,
                session
        };
    }

    public Response handler(WebContext webContext, IHTTPSession session){
        return new Response(session, Status.OK, MIME_HTML, "200");
    }

    @Override
    public Method getInvoker() {
        try {
            return HealthRequestMapperHandler.class.getMethod("handler", WebContext.class, IHTTPSession.class);
        } catch (Exception ex){
            return null;
        }
    }

    @Override
    public Object getTarget() {
        return this;
    }
}
